/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights
 * reserved. <a>http://www.cqcis.com</a>
 */
package com.cq.bd.dwr;

import java.util.List;
import java.util.Map;

import com.cq.base.domain.Page;
import com.cq.bd.base.BaseDwr;
import com.cq.bd.domain.SDepart;
import com.cq.bd.domain.SRegion;
import com.cq.bd.service.RegionService;

/**
 * 组织部门管理
 * 
 * @author huangmy
 * @date   2009-10-5
 */
public class RegionDwr extends BaseDwr {
    private static final long serialVersionUID = 1L;
    private RegionService regionService;
    
    /**
     * 创建组织
     * 
     * @param region
     */
    public void createRegion(SRegion region) {
        if (region.getUpperRegionId() == null) {
            region.setUpperRegionId(0L);
        }
        this.regionService.doCreateRegion(region);
    }
    
    /**
     * 修改组织
     * 
     * @param region
     */
    public void updateRegion(SRegion region) {
        this.regionService.doUpdateRegion(region);
    }
    
    /**
     * 删除组织
     * 
     * @param region
     */
    public void deleteRegion(SRegion region) {
        this.regionService.doDeleteRegion(region);
    }
    
    /**
     * 获取组织
     * 
     * @param upperRegionId  上级组织ID, 0 为顶级
     * @return
     */
    public List<SRegion> getRegions(Long upperRegionId) {
        return this.regionService.doGetRegions(upperRegionId);
    }
    
    /**
     * 所有的组织
     * 
     * @return
     */
    public List<SRegion> getAllRegions() {
        return this.regionService.doGetAllRegions();
    }
    
    /**
     * 分页查询
     * 
     * @param filter
     * @param like
     * @param sort
     * @param pageNo
     * @param pageSize
     * @return
     */
    public Page pageRegions(Map<String, String> filter, Map<String, String> like, Map<String, String> sort, int pageNo, int pageSize){
        return this.regionService.pageRegions(filter, like, sort, pageNo, pageSize);    
    }
    
    /**
     * 部门
     * 
     * @param filter
     * @param like
     * @param sort
     * @param pageNo
     * @param pageSize
     * @return
     */
    public Page pageDeparts(Map<String, String> filter, Map<String, String> like, Map<String, String> sort, int pageNo, int pageSize){
        return this.regionService.pageDeparts(filter, like, sort, pageNo, pageSize);    
    }
    
    public int checkRegionCode(String regionCode) {
        return this.regionService.checkRegionCode(regionCode);
    }
    
    public int checkDepartCode(String regionCode) {
        return this.regionService.checkDepartCode(regionCode);
    }
    
    /**
     * 获取组织
     * 
     * @param regionId
     * @return
     */
    public SRegion getRegion(Long regionId) {
        return this.regionService.doGetRegion(regionId);
    }
    
    /**
     * 创建部门
     * 
     * @param depart
     */
    public void createDepart(SDepart depart) {
        this.regionService.doCreateDepart(depart);
    }
    
    /**
     * 修改部门
     * 
     * @param depart
     */
    public void updateDepart(SDepart depart) {
        this.regionService.doUpdateDepart(depart);
    }
    
    public void deleteDepart(SDepart depart) {
        this.regionService.doDeleteDepart(depart);
    }
    
    /**
     * 获取所有的部门
     * 
     * @return
     */
    public List<SDepart> getDeparts() {
        return this.regionService.doGetDeparts();
    }
    
    /**
     * 获取所有的部门
     * 
     * @return
     */
    public List<SDepart> getDepartsByRegionId(Long regionId) {
        return this.regionService.doGetDepartsByRegionId(regionId);
    }
    
    /**
     * 所有的有效组织
     * 
     * @return
     */
    public List<SDepart> getValidDeparts() {
        return this.regionService.doGetValidDeparts();
    }
    
    /**
     * 获取部门
     * 
     * @param departId
     * @return
     */
    public SDepart getDepart(Long departId) {
        return this.regionService.doGetDepart(departId);
    }

    public void setRegionService(RegionService regionService) {
        this.regionService = regionService;
    }
}
